const {imgUrl} = getApp().globalData
import { mineApi } from "../../../utils/request/api/mine";
Page({
  data: {
    imgUrl: imgUrl + 'mine/',
    isEmpty: false,
    refresherStatus: false,
    list: [],
  },
  toSubDetail() {
    wx.navigateTo({
      url: "/pages/tender/subscribe/subinfo/subinfo",
    });
  },
  toSubDetail2(event) {
    const that = this;
    const index = event.currentTarget.dataset.index;
    wx.navigateTo({
      url: "/pages/tender/subscribe/addsub/addsub?type=edit",
      success: function (res) {
        const eventChannel = res.eventChannel;
        eventChannel.emit("sub_info", { data: that.data.list[index] });
      },
    });
  },
  deleteSub(event) {
    const index = event.currentTarget.dataset.index;
    mineApi.deleteSubscription({
      id: this.data.list[index].id
    }).then((res) => {
      this.getList()
    });
  },
  // 下拉刷新
  handleRefresherRefresh() {
		this.setData({
			refresherStatus: true,
		})
		this.getList()
	},
  getList() {
    mineApi.getSubscriptionList().then((res) => {
      this.setData({
        list: res.data,
        refresherStatus: false,
      })
    })
  },
  onLoad(options) {
    this.getList()
  },
  onReady() {
  },
  onShow() {
  },
  onHide() {
  },
  onUnload() {
  },
  onShareAppMessage() {
    return {
      title: '',
    };
  },
});